package com.fanhang.samples.spring.mybatis.dao.impl;

import java.util.List;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

import com.fanhang.samples.spring.mybatis.dao.UserDao;
import com.fanhang.samples.spring.mybatis.po.User;

/**
 * jdbc
 * @author fanhang
 *
 */
@Repository
public class UserDaoImpl extends SqlSessionDaoSupport implements UserDao {

	@Override
	public int save(User model) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int delete(User model) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int update(User model) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public User get(Long id) {
		return (User) super.getSqlSession().selectOne("get", id);
	}

	@Override
	public List<User> getList(User model) {
		// TODO Auto-generated method stub
		return null;
	}

//	@Override
//	public int save(User model) {
//		String sql = "insert into stat_user(id,login_name,password,user_name,role_id,status,creator,create_time) values (:id, :loginName, :password, :userName, :roleId, :status, :creator, :createTime)";
//		return super.update(sql, model);
//	}
//
//	@Override
//	public int delete(User model) {
//		String sql = "update employee set name=:name,birthday=:birthday,status=:status WHERE id = :id";
//		return super.update(sql, new BeanPropertySqlParameterSource(model));
//	}
//
//	@Override
//	public int update(User model) {
//		String sql = "update employee set name=:name,birthday=:birthday,status=:status WHERE id = :id";
//		return super.update(sql, new BeanPropertySqlParameterSource(model));
//	}
//
//	@Override
//	public User get(Long id) {
//		String sql = "SELECT * FROM stat_user WHERE id = ?";
//		return super.get(sql, new Long[]{id});
//	}
//
//	@Override
//	public List<User> getList(User model) {
//		StringBuilder sql = new StringBuilder("SELECT * FROM stat_user WHERE 1=1 ");
//		if (model.getRoleId() != null) {
//			sql.append(" and role_id = :roleId ");
//		}
//		if (model.getCreator() != null) {
//			sql.append(" and creator = :creator ");
//		}
//		if (!StringUtils.isEmpty(model.getUserName())) {
//			sql.append(" and user_name like '%:userName%' ");
//		}
//		return super.getList(sql.toString(), model, User.class);
//	}
}
